<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>图书管理系统 - 安装</title>
<style>
body{
    color:#444;
    font-size:12px;
    font-family:Arial;
    background:#F0F5F8;
}
a{
    text-decoration:none;
    color:#005EAC;
}
#main{
    width:760px;
    margin:10px auto;
    background:#fff;
    border:1px solid #eee;
    padding:15px;
}
h1{
    padding-bottom:10px;
    font-size:18px;
    border-bottom:1px solid #ddd;
}

ul.info{
    list-style:circle;
}
ul.info li{
    line-height:2;
}
ul.check {
    margin:10px 70px 0 10px;
    line-height:2;
}
ul.check li span{
    float:right;
}
.green{
    color:green;
}
.red{
    color:red;
}
.blue{
    color:#005EAC;
}
.orange{
    color:#ff9900;
}
input.btn{
    background-color:#005EAC;
    border-color:#B8D4E8 #124680 #124680 #B8D4E8;
    border-style:solid;
    border-width:1px;
    color:#FFFFFF;
    cursor:pointer;
    font-size:12px;
    height:23px;
    text-align:center;
}
table.setting{
    margin-left:40px;
}
table.setting th{
    width:150px;
    text-align:left;
}
</style>
<script>
function checkSubmit(o){
    if(o.dbadapter.value == 'mysql' || o.dbadapter.value == 'mysqli'){
        if(o.dbhost.value == ''){
            alert('数据库主机不能为空！');
            return false;
        }
    
        if(o.dbport.value == ''){
            alert('端口号不能为空！');
            return false;
        }
        if(o.dbhost.value == ''){
            alert('数据库主机不能为空！');
            return false;
        }
        if(o.dbuser.value == ''){
            alert('数据库用户名不能为空！');
            return false;
        }
        if(o.dbname.value == ''){
            alert('数据库名不能为空！');
            return false;
        }
    }else if(o.dbadapter.value == 'sqlite'){
        if(o.sqlitedbname.value == ''){
            alert('Sqlite数据库路径不能为空！');
            return false;
        }
    }else{
        alert('请选择数据库类型！');
        return false;
    }
    
    if(o.username.value == ''){
        alert('管理员用户名不能为空！');
        return false;
    }
    if(o.userpass.value == ''){
        alert('管理员密码不能为空！');
        return false;
    }
    
    if(o.passagain.value != o.userpass.value){
        alert('两次密码不一致！');
        return false;
    }
    
    if(o.url.value == ''){
        alert('站点URL不能为空!');
        return false;
    }
    o.submit();
}

function selected_adapter(val){
    if(val == 'sqlite'){
        document.getElementById('sqlite_div').style.display = '';
        document.getElementById('mysql_div').style.display = 'none';
        document.getElementById('dbauth_div').style.display = 'none';
        document.getElementById('pre_div').style.display = '';
    }else{
        document.getElementById('sqlite_div').style.display = 'none';
        document.getElementById('mysql_div').style.display = '';
        document.getElementById('dbauth_div').style.display = '';
        document.getElementById('pre_div').style.display = '';
    }
}
</script>
</head>
<body>
<div id="main">
    <h1 class="blue">欢迎使用图书管理系统！ <span class="orange">安装第二步：配置系统</span></h1>

<h2>数据库配置</h2>

<form action="index.php?step=3" method="post" onsubmit="checkSubmit(this);return false;"><table class="setting">
<tbody>
<tr><th>数据库类型</th><td>
    <select id="sel_dbadapter" name="dbadapter" onchange="selected_adapter(this.value)">
    <option value="mysql">Mysql</option>    </select></td>
</tbody>
<tbody id="mysql_div">

<tr><th>数据库主机</th><td><input name="dbhost" type="text" value="localhost" /></td>
<tr><th>端口号</th><td><input name="dbport" type="text" value="3306" /></td>
</tbody>
<tbody id="dbauth_div">
<tr><th>用户名</th><td><input name="dbuser" type="text" value="root" /></td>
<tr><th>密码</th><td><input name="dbpass" type="password" value="" /></td>
<tr><th>数据库名</th><td><input name="dbname" type="text" value="lib" />
</tbody>
<tbody id="pre_div">

<tr><th>表前缀</th><td><input name="dbpre" type="text" value="lib_" /></td>
</tbody>
</table>
<h2>管理员帐号</h2>
<table class="setting">
<tr><th>登录名</th><td><input name="username" type="text" value="admin" /></td>
<tr><th>登录密码</th><td><input name="userpass" type="password" value="" /></td>
<tr><th>密码确认</th><td><input name="passagain" type="password" value="" /></td>

</table>
<h2>其他设置</h2>
<table class="setting">

<tr><th>站点URL</th><td><input name="url" size="40" type="text" value="<?php echo get_url();?>" /> 请带上URL末端的"/" </td>
</table>
<div align="left" style="margin-top:10px;padding-left:200px"><input type="button" onclick="window.history.back()" value="上一步" class="btn" />&nbsp;&nbsp;&nbsp;&nbsp; <input type="submit" value="立即安装" class="btn" /></div></form>
<script>selected_adapter(document.getElementById("sel_dbadapter").value);</script>

 </div>

</body>
</html>